<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<%=basePath%>static/css/sidebar_css.css" rel="stylesheet" />
<link href="<%=basePath %>static/css/center.css" rel="stylesheet" />
<link href="<%=basePath %>static/css/common.css" rel="stylesheet" />
<link rel="stylesheet" href="<%=basePath%>static/css/jquery-ui.min.css" />
<link rel="stylesheet" href="<%=basePath%>static/css/jquery-ui-timepicker-addon.min.css" />
<link href="<%=basePath%>bootstrap/bootstrap.min.css" rel="stylesheet" />
<script type="text/javascript"
	src="<%=basePath%>static/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript"
	src="<%=basePath%>bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" 
	src="<%=basePath%>static/js/jquery-ui.min.js"></script>
<script type="text/javascript"
	src="<%=basePath%>static/js/jquery-ui-timepicker-addon.min.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
$(function(){
	
});
function editSubmit(){
	var password = $("#password").val();
	var newPassword = $("#newPassword").val();
	var confirmPassWord = $("#confirmPassWord").val();
	if(password==null || password=="") {
		alert("旧密码不能为空");
		return false;
	}
	if(newPassword==null || newPassword=="") {
		alert("新密码不能为空");
		return false;
	}
	if(confirmPassWord==null || confirmPassWord=="") {
		alert("密码确认不能为空");
		return false;
	}
	if(newPassword!=confirmPassWord) {
		alert("新密码两次不一致");
		return false;
	}
	$.ajax({
		url:"<%=basePath%>users/editPassword",
		type:"post",
		data:{password:password,newPassword:newPassword},
		success:function(result) {
			if(result==0) {
				alert("旧密码不正确");
			} else if (result==1) {
				alert("密码修改成功");
				$("#password").val("");
			 	$("#newPassword").val("");
				$("#confirmPassWord").val("");
			} else {
				alert("密码修改失败");
			}
		},
		error:function() {
			alert("程序出错");
		}
	});
}
</script>
</head>
<body>
<h4 style="text-align: center; font-family: 楷体; font-weight: bold;">密码修改</h4>
<div class="container">
	<div class="lay-bd">
		<div class="row">
			<div class="panel panel-default">
  				<div class="panel-heading">	
  					<!-- <span class="required">*</span> 原密码：
  					<div class="form-group">
   						 <input type="text" class="form-control" placeholder="Search">
  					</div> -->
  					<div class="panel panel-info">
						<div class="panel-heading">原密码：</div>
						<div class="panel-body">							   
							<div class="form-group">
								<input id="password" name="password"
											class="form-control" maxlength="25" type="password" placeholder="请输入旧密码">
			  				</div>
						</div>
					</div>
					<div class="panel panel-info">
						<div class="panel-heading">新密码(需包含字母、数字、下划线中不少于两种且长度不少于6)：</div>
						<div class="panel-body">							   
							<div class="form-group">
								<input id="newPassword" name="newPassword"
											class="form-control" maxlength="25" type="password" value="" placeholder="请输入新密码">
			  				</div>
						</div>
					</div>
					<div class="panel panel-info">
						<div class="panel-heading">密码确认：</div>
						<div class="panel-body">							   
							<div class="form-group">
								<input id="confirmPassWord" name="confirmPassWord"
											class="form-control" maxlength="25" type="password" placeholder="请再次输入新密码">
			  				</div>
						</div>
					</div>
					<div>
<!-- 					<a href="javascript:cancelSubmit();"  onclick="cancelSubmit();" role="button" class="btn btn-info" style="margin-left: 350px;">取消</a>
 -->					<a href="javascript:void(0);"  onclick="editSubmit();" role="button" class="btn btn-info" style="margin-left: 350px; ">确认修改</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>